<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>第6单元日考测试</title>
    <style>
        #price {
            color: red;
            font-size: 30px;
        }

        #sale {
            display: inline-block;
            background: yellow;
            width: 120px;
            height: 60px;
            text-align: center;
            color: red;
            line-height: 60px;
        }
    </style>
</head>

<body>
    <h2>促销商品</h2>
    <p>苹果，原价<del id="price">8.9</del>/斤</p>
    <p>苹果，现价<span id="sale"></span></p>
    <script>
        // (1)获取苹果的原价（20分）
        var price = document.getElementById("price").innerHTML
        console.log(price)
        // (2)苹果的现价是5折处理，请计算苹果的现价，并保留两位小数（20分）
        var currPrice = price * 0.5
        console.log(currPrice)
        // (3)将苹果现价以“价格 / 斤”的格式显示到页面黄框内(20分)
        document.getElementById("sale").innerHTML = currPrice + "/ 斤"
    </script>
</body>

</html>